﻿
@section ScriptAndCss{
    <link href="@Url.Content("~/Content/css/plan.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/json3.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/plan.js")" type="text/javascript"></script>
}

<script type="text/javascript">

        var DateFormate = function (value, row, index) {
            if (value) {
                return value.DateStringConvert('yyyy-MM-dd');
            }
        };

        var OpeRender = function () {
            return '<a class="deleteRow">删除</a>';
        };

        var Upfiles = function (value, row, index) {
            if (value) {
                return "<a href='" + row["Url"] + "'>" + value + "</a>";
            }
        };

        $(function () {
            $('#dg').datagrid({
                onLoadSuccess: function (data) {
                    $(".note").tooltip({
                        onShow: function () {
                            $(this).tooltip('tip').css({
                                width: '300',
                                boxShadow: '1px 1px 3px #292929'
                            });
                        }
                    });
                },
                onDblClickRow: function (rowIndex, rowData) {
                    var rnd = (new Date()).getMilliseconds() + "" + parseInt(Math.random() * 10000);
                    $.ajax({
                        url: 'OpsReport/GetURL',
                        data: { ID: rowData.ID, nocatch: rnd },
                        success: function (result) {
                            window.open(encodeURI(result) + "catchid=" + rnd);
                        }

                    });
                },
                onClickCell: function (rowIndex, field, value) {
                    if (field == "Ope") {
                        $.messager.confirm('提醒', '确认删除这个文件吗？', function (r) {
                            if (r) {
                                $.post('/OpsReport/FileDelete', {
                                    ID: $('#dg').datagrid('getData').rows[rowIndex]["ID"]
                                }, function (res) {
                                    if (res == "OK") {
                                        $.messager.alert('提示', '删除成功!', 'info');
                                        $('#dg').datagrid('reload');
                                    }
                                    if (res == "Error") {
                                        $.messager.alert('错误', '删除失败!', 'error');
                                    }
                                    if (res == "Warning") {
                                        $.messager.alert('警告', '该文件不是您上传的，您不具备删除权限!', 'warning');
                                        $('#dg').datagrid('reload');
                                    }
                                });
                                $('#dg').datagrid('deleteRow', rowIndex);
                            }
                        });
                    }
                }

            });



            $('#dg').datagrid("hideColumn", 'ID');
            var p = $('#dg').datagrid('getPager');

            $(p).pagination({
                beforePageText: '第',

                afterPageText: '页    共 {pages} 页',

                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'

            });

        });
    </script>

<div class="easyui-panel" title="运维报告列表" data-options="tools:'#todoMore'">
    <table id="dg" style="height: 250px;" class="easyui-datagrid" pagination="true" url="/OpsReport/OpsList" fitcolumns="true" singleselect="true">
        <thead>
            <tr>
                <th field="ID">ID</th>
                <th field="DName" width="10%" sortable="true">名称</th>
                <th field="Keywords" width="20%" sortable="true">关键字</th>
                <th field="FileName" formatter="Upfiles" width="40%" sortable="true">文件</th>
                <th field="CreateTime" width="10%" formatter="DateFormate" sortable="true">发布时间</th>
                <th field="Submitter" width="10%" sortable="true">发布人</th>
                <th field="Ope" width="10%" formatter="OpeRender">操作</th>
            </tr>
        </thead>
    </table>
</div>

